package com.queclink.ycm.entity.data.useless;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.queclink.ycm.common.utils.HexUtils;
import com.queclink.ycm.entity.data.Data;

/**
 * @author jim.li
 * @email jim.li@queclink.com
 * @date 2021-12-27 11:55:00
 */
public class Data142 extends Data {

    @JSONField(
            name = "CrashID"
    )
    private String CrashID;
    @JSONField(
            name = "PeakAcceleration"
    )
    private String PeakAcceleration;

    public String getCrashID(JSONObject jsonObject) {
        StringBuffer sb = new StringBuffer();
        Integer crashID = jsonObject.getInteger("CrashID");
        String s = HexUtils.intToHex(crashID, 2);
        sb.append(s);
        return sb.toString();
    }

    public void setCrashID(String crashID) {
        CrashID = crashID;
    }

    public String getPeakAcceleration(JSONObject jsonObject) {
        StringBuffer sb = new StringBuffer();
        Integer peakAcceleration = jsonObject.getInteger("PeakAcceleration");
        String s = HexUtils.intToHex(peakAcceleration, 4);
        sb.append(s);
        return sb.toString();
    }

    public void setPeakAcceleration(String peakAcceleration) {
        PeakAcceleration = peakAcceleration;
    }

    public String getDataID() {
        // data142
        return "808e";
    }

    public String getLength() {
        return "03";
    }

    @Override
    public String combine(JSONObject jsonObject) throws Exception {
        StringBuffer sb = new StringBuffer();
        sb.append(this.getDataID());
        sb.append(this.getLength());
        sb.append(this.getCrashID(jsonObject));
        sb.append(this.getPeakAcceleration(jsonObject));
        return sb.toString();
    }
}
